Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pie chart data lables #1885

Merged
merged 22 commits into from
Jan 2, 2025
Merged

Conversation

aestoltm
Copy link
Contributor

@aestoltm aestoltm commented Jul 15, 2024

Risk: LOW
Severity: MEDIUM (heavily affects readability of some pie charts)

Description

These changes fix the pie chart margin for when very long data labels are showing.

Also discovered that pie chart margin for some of the interactive charts have clipping with the data labels. This fix is non-trivial and will require some more effort in a separate PR. This is because the margin for pie charts may need to be re-worked entirely due to interactions with the subtitle, and different legend locations.

Motivation and Context

Pie charts with long data labels were barely visible

Tests performed

Tested on xdmod-dev

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

@aestoltm aestoltm requested review from jpwhite4 and connersaeli July 15, 2024 18:20
@aestoltm aestoltm added this to the 11.0.1 milestone Oct 2, 2024
@aestoltm aestoltm modified the milestones: 11.0.1, 11.0.2 Oct 4, 2024
@aestoltm aestoltm changed the base branch from main to xdmod11.0 November 22, 2024 19:00
@aestoltm aestoltm added the bug Bugfixes label Dec 3, 2024
@aestoltm aestoltm changed the title Fix exported pie chart margin Fix pie chart data lables Dec 17, 2024
if ($isThumbnail || ($labelsAllocated < $labelLimit && (($yValues[$i] / $pieSum) * 100) >= 2.0)) {
$label = $xValues[$i];
// Truncate long data labels to improve visibility.
if (strlen($xValues[$i]) >= 70) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (strlen($xValues[$i]) >= 70) {
if (mb_strlen($label) >= 70) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why only keep 40 characters but have the threshold set to 70 bytes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if 69 characters fits then why not have:

if (mb_strlen($label) >= LABLE_TRUNCATE_LEN) {
   $label = mb_substr($label, 0, LABLE_TRUNCATE_LEN - 3) . '...';
}

where LABLE_TRUNCATE_LEN would be set to something sensible (presumably between 40 and 70).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I had those set so differently. Should be addressed now.

@aestoltm aestoltm requested a review from jpwhite4 January 2, 2025 21:04
@aestoltm aestoltm merged commit 18c0fb4 into ubccr:xdmod11.0 Jan 2, 2025
4 checks passed
@aestoltm aestoltm deleted the plotly_pie_chart_margin branch January 2, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugfixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants